import re

def check_free_food(body_text):
    """
    Given the body_text of an email, scans for tale tell signs of free food.
    returns a Tuple (boolean, confidence, (food_class, food_type))
    """
    
    #We break email to sentences
    
    sents = re.split('[.!\n]+', body_text)
    check_sents = []
    for s in sents:
        s = s.strip()
        if s: check_sents.append(s)
        
    food_class =  re.compile('(lunch|dinner|breakfast|snack[s]?)', re.I)
    food_type = re.compile('(food|catered|catering|reception|refreshment[s]?|sandwich[s]?|pizza|qudoba|zingerman|jimmy john|potbelly|gyro[s]?|tea\s)', re.I)
    support = re.compile('(free|provided|served)',re.I)
    
    food_max = 0
    meal = ''
    meal_type = ''
    for s in check_sents:
        local_max = 0
        f_class = ''
        f_type = ''
        fc = food_class.search(s)
        ft = food_type.search(s)
        sp = support.search(s)
        if fc:
            local_max += 2
            f_class = fc.group(0)
        if ft:
            local_max += 2
            f_type = ft.group(0)
        if sp: local_max +=1
        if local_max >=2 and local_max > food_max:
            food_max = local_max
            meal = f_class
            meal_type = f_type
    
    conf = {2:'likely', 3:'yep', 4:'mos def', 5:'mos def'}
    if food_max >= 2:
        return (True,conf[food_max],(meal, meal_type))
    else:
        return (False,'', ()) 